package org.dairy.farms.nandana.core.logic;

import org.dairy.farms.dao.RevenueDAO;
import org.dairy.farms.model.LactationRevenue;
import org.dairy.farms.model.LivestockRevenue;
import org.dairy.farms.model.Revenue;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by IntelliJ IDEA.
 * User: gduggirala
 * Date: 25/2/13
 * Time: 5:58 PM
 */
@Service(value = "revenueManagementLogic")
public class RevenueManagementLogicImpl{//} implements RevenueManagementLogic {
    @Autowired
    RevenueDAO revenueDAO;

    /*@Override
    public List<Revenue> getLivestockRevenue(Long livestockId) {
        List<Revenue> livestockRevenueList = revenueDAO.findByLivestockId(livestockId);
        return filterByLivestockById(livestockRevenueList, livestockId);
    }

    *//*
     Could not filter the livestock id in the SQL criteria must find a way to remove that.
     *//*
    private List<Revenue> filterByLivestockById(List<Revenue> livestockRevenueList, Long livestockId) {
        List<Revenue> revenueList = new ArrayList<Revenue>();
        for (Revenue revenue : livestockRevenueList) {
            if (revenue instanceof LactationRevenue && ((LactationRevenue) revenue).getLactation().getLivestock().getId().equals(livestockId)) {
                revenueList.add(revenue);
            }
            if (revenue instanceof LivestockRevenue && ((LivestockRevenue) revenue).getLivestock().getId().equals(livestockId)) {
                revenueList.add(revenue);
            }
        }
        return revenueList;
    }*/
}
